package test;

import com.eviware.soapui.impl.WorkspaceImpl;
import com.eviware.soapui.impl.WsdlInterfaceFactory;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlRequest;
import com.eviware.soapui.impl.wsdl.WsdlSubmit;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.model.iface.Operation;
import com.eviware.soapui.model.iface.Request;
import com.eviware.soapui.model.iface.Response;
import com.eviware.soapui.model.iface.TypedContent;
import com.eviware.soapui.model.workspace.Workspace;

public class SOAPUI {

	
	 static String x="https://strl069163.mso.net:10604/finGlDesktopEntry/JournalImportService?wsdl";
	 
	 
	 static String y="https://wd2-impl-services1.workday.com/ccx/service/pwc_dpt1/Staffing/v25.0?wsdl";
	 
	 
	public static void main(String[] args)throws Exception,org.apache.xmlbeans.XmlException {
		
		
		
		WsdlProject project = new WsdlProject();
			
		WsdlInterface iface = WsdlInterfaceFactory
				.importWsdl(
						project,
						x,
						true)[0];
				
			
		Operation [] ops= iface.getAllOperations();
		
		
		Operation op=ops[1];
		
		
		WsdlRequest req=(WsdlRequest) op.getRequestAt(0);
		
		//req.getName();
		
		//op.getRequestList()
		
		
		String payload="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"+
		"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:wd=\"urn:com.workday/bsvc\">"+
		"<soapenv:Header/>"+"<soapenv:Body>"+
		" <wd:Put_Applicant_Request wd:version=\"v25.0\">"+
		"<wd:Applicant_Data>"+"<wd:Personal_Data>"+"<wd:Name_Data>"+" <wd:Legal_Name_Data>"
		+" <wd:Name_Detail_Data>"+"<wd:Country_Reference>"+"<wd:ID wd:type=\"ISO_3166-1_Alpha-3_Code\">USA</wd:ID>"
		+"</wd:Country_Reference>"+"<wd:First_Name>Mess0</wd:First_Name>"+"<wd:Last_Name>Willam0</wd:Last_Name>"+
		"</wd:Name_Detail_Data>"+"</wd:Legal_Name_Data>"+"</wd:Name_Data>"+"<wd:Contact_Data>"+"<wd:Address_Data>"+
		"<wd:Country_Reference>"+"<wd:ID wd:type=\"ISO_3166-1_Alpha-2_Code\">US</wd:ID>"+
		"</wd:Country_Reference>"+
		"<wd:Address_Line_Data wd:Descriptor=\"Address Line 1\" wd:Type=\"ADDRESS_LINE_1\">116 Fairview St.</wd:Address_Line_Data>"
		+"<wd:Municipality>Hallsville</wd:Municipality>"+
		"<wd:Country_Region_Reference>"+
		"<wd:ID wd:type=\"Country_Region_ID\">USA-MO</wd:ID>"+
		"</wd:Country_Region_Reference>"+
		"<wd:Postal_Code>65255</wd:Postal_Code>"+
		"<wd:Usage_Data wd:Public=\"false\">"+
		"<wd:Type_Data wd:Primary=\"true\">"+
		"<wd:Type_Reference>"+
		"<wd:ID wd:type=\"Communication_Usage_Type_ID\">Home</wd:ID>"+
		" </wd:Type_Reference>"+
		"</wd:Type_Data>"+
		"</wd:Usage_Data>"+
		" </wd:Address_Data>"+
		"</wd:Contact_Data>"+
		"</wd:Personal_Data>"+
		"</wd:Applicant_Data>"+
		"</wd:Put_Applicant_Request>"+
		"</soapenv:Body>"+
		"</soapenv:Envelope>"
		
		;
		
//		String payload=
//		"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:typ=\"http://xmlns.oracle.com/apps/financials/generalLedger/journals/desktopEntry/journalImportService/types/\" xmlns:jour=\"http://xmlns.oracle.com/apps/financials/generalLedger/journals/desktopEntry/journalImportService/\" xmlns:acc=\"http://xmlns.oracle.com/apps/financials/generalLedger/accounts/codeCombinations/publicFlex/Account/\">"+
//		"<soapenv:Header/>"+
//		"<soapenv:Body>"+
//		"<typ:importJournals>"+
//		"<typ:interfaceRows>"+
//		" <jour:BatchName>test</jour:BatchName>"+
//		" </typ:interfaceRows>"+
//		" </typ:importJournals>"+
//		"</soapenv:Body>"+
//		"</soapenv:Envelope>";
		
		            
		req.setRequestContent(payload);
		
		
		req.setUsername("hyang-impl@pwc_dpt1");
		
		req.setPassword("Underall1@");
		
		req.setWssPasswordType("PasswordText");
		
		
		
			
		String reqStr= req.getRequestContent();
		
		WsdlSubmit submit = (WsdlSubmit) req.submit( new WsdlSubmitContext(req), false );
		
		Response response=(Response) submit.getResponse();		
		
		
		
		//String s=op.createRequest(true);
		
		
		//req.submit( new WsdlSubmitContext(), false);
		
		
		
		
		//System.out.println(s);			
		
		System.out.println(op.getName());
		
		System.out.println("---begin----");
		System.out.println(response.getContentAsString());
		
		//System.out.println(reqStr);
		
		System.out.println("---END----");
		
		
		
		/*
		

		WsdlProject project = new WsdlProject();

		WsdlInterface iface = WsdlInterfaceFactory
				.importWsdl(
						project,
						"https://strl069163.mso.net:10604/finGlDesktopEntry/JournalImportService?wsdl",
						true)[0];
		
		
		// get desired operation
		
		WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "MyOperation" );
	
		 
	
		// create a new empty request for that operation
		
		WsdlRequest request = operation.addNewRequest( "My request" );
		
		 
		
		// generate the request content from the schema
		
		request.setRequestContent( operation.createRequest( true ) );
		
		 
		
		// submit the request
		
		WsdlSubmit submit = (WsdlSubmit) request.submit( new WsdlSubmitContext(request), false );
		
		 
		
		// wait for the response
	
		Response response = (Response) submit.getResponse();
		
		 
		
		//  print the response
		
		String content = ((TypedContent) response).getContentAsString();
	
		System.out.println( content );
	*/
		

	}

}
